﻿using UnityEngine;
using System.Collections;
using DICE_GS;

public class RewardCard : MonoBehaviour {
	public UISprite itemImage;
	public UILabel itemAmount;
	public RandomBoxSelectWindow window;
	public int index;

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
	
	}

	void OnClick()
	{
//		GetComponent<Animator>().enabled = true;
		window.SelecteBox(index, index, null);
	}

	Vector3 originPos;
	public void MoveToCenterOfScreen()
	{
		originPos = transform.parent.localPosition;
		TweenPosition twPosition = transform.parent.gameObject.AddComponent<TweenPosition>();
		twPosition.from = transform.parent.localPosition;
		twPosition.to = new Vector3(14f, 0f, 0f);
		twPosition.duration = 0.25f;
		twPosition.delay = 0f;
		twPosition.PlayForward();
	}

	public void MoveToOriginPosition()
	{
		TweenPosition twPosition = transform.parent.GetComponent<TweenPosition>();
		twPosition.from = transform.parent.localPosition;
		twPosition.to = originPos;
		twPosition.duration = 2f;
		twPosition.delay = 0f;
		twPosition.PlayForward();
	}

	public void SetItemInfos(BoxCategory category, int boxID, int amount )
	{
		if( CItemDataManager.Instance.GetItemData(boxID).id == 2 )
		{
//			itemName.text = "COIN";
			itemAmount.text = amount.ToString();
			itemImage.spriteName = "RewardItemIcon_Gold";
		}
		else if( CItemDataManager.Instance.GetItemData(boxID).id == 1 )
		{
//			itemName.text = "DIAMOND";
			itemAmount.text = amount.ToString();
			itemImage.spriteName = "RewardItemIcon_Cash";
		}
		
//		itemName.gameObject.SetActive(false);
//		itemAmount.gameObject.SetActive(false);
//		itemImage.gameObject.SetActive(false);
	}

	public void ShowUnitCard()
	{
		window.ShowUnitCard(index);
	}
}
